<?php
$cs = Yii::app()->getClientScript();
$cs->registerCSSFile(Yii::app()->request->baseUrl . '/css/mobile/booking_find_1.css');
?>
<?php
$screen = Blyn::app()->getUIManager()->getCurrentScreen();
$wxControl = $screen->getChildControl('BUIWXControl_1');
$wxControl->renderView('booking_home', array());
$bookingItem = new BWInputValue($bookingId);
$bookingList = new BTreeList($bookingItem);
//get user
$user = Blyn::app()->getCurrentUser();
?>
<?php
$url = $control->getAjaxLinkUrl('addToBookingCart_1', 'addToBookingCart_1', array(
    'bookingId' => $bookingId));
$updateId = $control->getAjaxContainerId();
?>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style>
.album {
    height: 3.9rem;
    position: relative;
    overflow: hidden;
}

.album img {
    width: 100%;
    min-height: 100%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    -moz-transform: translateY(-50%);
    top: 50%;
    position: relative;
}

.album .desc {
    position: absolute;
    bottom: 0;
    width: 100%;
    color: white;
    text-align: center;
    height: .56rem;
    line-height: .56rem;
    font-size: .24rem;
    background: rgba(0, 0, 0, .5);
}

ul.ul {
    list-style-type: initial;
    padding-left: .4rem;
}

ul.ul li {
    font-size: .3rem;
    margin: .1rem 0;
    line-height: 1.5;
}

    /*///*/
#deal-detail .buy-price {
    color: #999;
    position: relative;
}

.buy-price .price {
    vertical-align: text-top;
}

.buy-price strong {
    font-size: .66rem;
}

.buy-price space {
    width: .16rem;
}

.buy-price .buy-btn {
    position: absolute;
    right: .2rem;
    top: .21rem;
    //width: 2.6rem;
}

.buy-desc h1 {
    font-size: .36rem;
    margin: 0;
    margin-bottom: .22rem;
    color: #000;
}

.buy-desc p {
    margin: 0;
    color: #666;
}
</style>
</head>
<body>
    <header class="navbar">
                <div class="nav-wrap-left">
                    <a class="react back" href="<?php echo $wxControl->getLinkUrl(array('name' => '返回列表', 'id' => 'showBookingList_1'), array('findText' => $findText,'flagText'=>$flagText)); ?>"><i class="text-icon icon-back"></i></a>
                </div>
            <h1 class="nav-header"><?php echo $flagText;?></h1>

        <?php
        $screen = Blyn::app()->getUIManager()->getCurrentScreen();
        $wxControl = $screen->getChildControl('BUIWXControl_1');
        $wxControl->renderView('booking_navigation', array());
        ?>
        </header>
<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "post-form-2",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
));
?>
<script type="text/javascript">
function loaderDiv() {
    document.getElementById("ajax-loaderdiv").style.display = "block";
}
</script>
<div id="deal" class="deal">
      <?php if ($bookingList instanceof BTreeList) { ?>
<div class="list">
    <div class="album">
        <?php
            $str = $bookingList->getItem('courtName')->value;
            $bookingStatus = $bookingList->getItem('bookingStatus')->value;
            //$longitude = $bookingList->getItem('longitude')->value;
           // $latitude = $bookingList->getItem('latitude')->value;
            $bookItem = new BWInputValue($bookingId);
            $bookList = new BTreeList($bookItem);
            $addToBookingCartTimeItem = $bookList->getItem('addToBookingCartTime');
            if ($addToBookingCartTimeItem instanceof BTreeItem) {
                $addToBookingCartTime = $addToBookingCartTimeItem->value;
                if ($addToBookingCartTime + 15 * 60 > time()) {
                    $bookingStatus = 'unpaid';
                }
            }
            
            $str = trim($str);
            if (!empty($str)) {
                $result = '';
                for ($i = 0; $i < strlen($str); $i++) {
                    if (is_numeric($str[$i])) {
                        $result.=$str[$i];
                    }
                }
            }
            $bookdetail = new BWMessage($result);
            
            $longitudeMedia = $bookdetail->getMediaManager()->getMedia('longitude');
            if($longitudeMedia instanceof BWMedia)
            {
                $longitude = $longitudeMedia->getContent(); ?>
        <input id="jing" type="hidden" value="<?php echo $longitude; ?>"/>
        <?php }
            $latitudeMedia = $bookdetail->getMediaManager()->getMedia('latitude');
            if($latitudeMedia instanceof BWMedia)
            {
                $latitude = $latitudeMedia->getContent(); ?>
              <input id="wei" type="hidden" value="<?php echo $latitude; ?>"/>      
        <?php }
            $courtImageMedia = $bookdetail->getMediaManager()->getMedia('image');
            if ($courtImageMedia instanceof BWMedia) {
                $courtImage = $bookdetail->getMediaManager()->getMedia('image')->getContent();
                ?>
                <img src="<?php echo Yii::app()->request->baseUrl . $courtImage; ?>"/>
            <?php } else { ?>
                <h4>No Picture!</h4>
        <?php } ?>
        <div class="desc"><?php echo $bookingList->getItem('courtDisplayName')->value; ?></div>
    </div>
    <dl class="list list-in">
        <dd class="dd-padding buy-price">
            <div class="price">
                <strong class="J_pricetag strong-color"><?php echo $bookingList->getItem('price')->value; ?></strong><span class="strong-color">元</span>
            </div>
            <?php
            if($bookingStatus == 'available') {?>
                <span class="wrapper buy-wrapper" onclick="loaderDiv()">
                    <?php echo $wxControl->getLink(array('name' => '加入预订清单', 'id' => 'addToBookingCart_1'), array('bookingId' => $bookingId, 'findText' => $findText,'flagText'=>$flagText, 'findContext' => $findContext,  'userId' => $user->getId(), 'htmlOptions' => array('class' => 'btn btn-strong btn-tip  buy-btn btn-large'))); ?>
                </span>
            <?php } else {?>
                <span class="wrapper buy-wrapper">
                    <p class="btn btn-strong btn-tip  buy-btn btn-large" style="background-color: #dedede">已加入预订清单</p>
                </span>
            <?php }?>
            
        </dd>
        <dd class="dd-padding buy-desc">
            <h1><?php echo $bookingList->getItem('courtDisplayName')->value; ?></h1>
            <ul class="ul">
                    <li>场地开始时间(0-23):<span style="font-family: inherit;font-weight: bold;padding: 5px;">
                                <?php
                                $startTime = $bookingList->getItem('startTime')->value;
                                echo date('Y-m-d G:i:s', $startTime);
                                ?></span></li>
                    <li>场地结束时间(0-23):<span style="font-family: inherit;font-weight: bold;padding: 5px;"><?php
                                               $endTime = $bookingList->getItem('endTime')->value;
                                               echo date('Y-m-d G:i:s', $endTime);
                                               ?></span></li>
                    <li>详细地址:<span id="address"><span style="font-family: inherit;
    font-weight: bold;padding: 5px;"><?php echo $bookingList->getItem('courtAddress')->value; ?></span></span></li>
                    <li>简介:<span style="font-family: inherit;
    font-weight: bold;padding: 5px;"> <?php echo $bookingList->getItem('courtDescription')->value; ?></span></li>
                    
                    <li style="position: relative;">  <span>场馆位置</span>
                        <style type="text/css">
                         #allmap {width:400px;height: 260px;overflow: hidden;margin:0;font-family:"微软雅黑";}
                        </style>
                        <div id="allmap"></div>
                        <script type="text/javascript">
                                //百度地图API功能
                                (function(){ window.BMap_loadScriptTime = (new Date).getTime(); window.BMap=window.BMap||{};window.BMap.apiLoad=function(){delete window.BMap.apiLoad;if(typeof init=="function"){init()}};var s=document.createElement('script');s.src='http://api.map.baidu.com/getscript?v=2.0&ak=258b70c4a5648db1e0a306d017a3c8f6&services=&t=20140930184510';document.body.appendChild(s);})();
                    function init() {
                                x=document.getElementById('jing').value;
                                y=document.getElementById('wei').value;
                                var point = new BMap.Point(x, y);
                                var map = new BMap.Map("allmap");   
                                map.centerAndZoom(point, 15);
                                
                                map.enableScrollWheelZoom();                 //启用滚轮放大缩小
                                var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
                                var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
                                var top_right_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}); //右上角，仅包含平移和缩放按钮
                                map.addControl(top_left_control);        
                                map.addControl(top_left_navigation);     
                                map.addControl(top_right_navigation);   
                                
                                var address= document.getElementById("address").innerHTML;
                                var marker = new BMap.Marker(point);  
                                map.addOverlay(marker);       
                                marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                                var label = new BMap.Label(address,{offset:new BMap.Size(15,-30)});
                                marker.setLabel(label);
                    }
                        </script>

                    </li>
                <li>我的会员卡号:<span style="font-family: inherit;  font-weight: bold;padding: 5px;"> <?php echo $user->getId(); ?></span></li>
                </ul>
        </dd>
    </dl>
</div>
<?php } ?>
<?php
if($bookingStatus == 'available') {?>
    <div class="wrapper buy-wrapper" onclick="loaderDiv()">
        <?php echo $wxControl->getLink(array('name' => '加入预订清单', 'id' => 'addToBookingCart_1'), array('bookingId' => $bookingId,'flagText' => $flagText, 'findText' => $findText, 'findContext' => $findContext,'userId' => $user->getId(),  'htmlOptions' => array('class' => 'btn btn-strong btn-tip  buy-btn btn-block btn-larger'))); ?>
    </div>
<?php } else {?>
    <div class="wrapper buy-wrapper">
        <p class="btn btn-strong btn-tip  buy-btn btn-large"style="width:100%;background-color: #dedede">已加入预订清单</p>
    </div>
<?php }?>


</div>
 <?php $this->endWidget(); ?>
<div id="ajax-loaderdiv" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;">
    <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader"style="position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;"/>
</div>
<footer>
        <div class="footer-copyright">
            <div class="hr"></div>
            <span class="footer-copyright-text">
			Copyright © 2014 billyn.net </span>
        </div>
    </footer>